<?php

class AutoIdResolve extends CActiveRecordBehavior {
	public $uid = 'uid';
	public function beforeValidate($event) {
		$model = $this->owner;
		$user = Yii::app()->adminUser;
		switch($user->role) {
			case AdminUser::ROLE_PROVIDER :
				$this->owner->{$this->uid} = $user->id; break;
			case AdminUser::ROLE_DEALER :
				$this->owner->{$this->uid} = $user->id; break;
		}
	}
}

?>